;;; Grind GNU Emacs DOC file into LaTeX input
;;; Copyright (C) 1987 Kyle E. Jones, Tor Lillqvist
;;; This file may be redistributed provided the above copyright
;;; notice appears on all copies and that the further free redistribution
;;; of this file is not in any way restricted by those who
;;; redistribute it.
;;; Based on Kyle E. Jones's grind-DOC package.
;;; This software is distributed 'as is', without warranties of any kind.
;;; This file is not part of GNU Emacs.
;;; The document that is the output from the (LaTeXify-DOC) function is
;;; part of GNU Emacs.
(defvar LaTeXify-DOC-style "report"
"*Should be bound to a string indicating what LaTeX document style
should be used to format the DOC file. If this variable is set to nil
the report style will be used.")
(defvar LaTeXify-DOC-style-options ""
"*A string containing a list of document style options for LaTeX")
(defun LaTeXify-DOC () (interactive)
"Reads the etc/DOC-xx.xx.x file into a buffer and converts it to a form
suitable as LaTeX input."
;
; Make sure we can deal with the macro package and the point size.
;
(cond
((not (stringp LaTeXify-DOC-style))
(error "LaTeXify-DOC-style must be a string")))
;
; Select the DOC file.
;
(find-file (expand-file-name
(if (fboundp 'dump-emacs)
(concat "DOC-" emacs-version)
"DOC")
exec-directory))
(setq buffer-read-only nil)
(auto-save-mode 0)
(set-visited-file-name (concat (buffer-file-name) ".tex"))
(delete-other-windows)
;
; Save-excursion just in case the DOC file was already selected.
;
(save-excursion
(let (case-fold-search mode-line-format varstart-point bufstring name odot)
;
; The first thing we must do is convert the
COMMAND]
sequences;
intothekeysthattheCOMMANDsareboundto.;(
setqmode -
line -
format"
GrindingtheDOCfile...
bepatient.")(
sit -
for0)(
replace -
regexp"
(
s
|
sw
)*""]]
bgroup]]
obeylines
& ]]
egroup")(
setqbufstring(
substitute -
command -
keys(
buffer -
string)))(
erase -
buffer)(
insertbufstring);;
HerewemakeeachdocstringbeginandendwithC -
for;
easiermanipulation.
Thisisundonelater.;(
goto -
char(1 + (
point -
min)))(
replace -
string"
-
""
-
-
"nil )(
goto -
char(
point -
max))(
insert"
-
");;
Sortthedocstrings.
Thisimplicitlyseparatesfunction;
documentationfromthevariabledocumentation.;(
sort -
regexp -
fieldsnil"
-
([
FV].*
)[
-
]*
-
""
1"(
point -
min)(
point -
max));;
HandleTeXspecialcharacters;(
goto -
char(
point -
min))(
mapcar'(
lambda(
x)(
save -
excursion(
evalx)))'((
replace -
string"#""]]#")(
replace -
string"$""]]$")(
replace -
string"(
replace -
string" & ""]] & ")(
replace -
string" ""]]
verb + + ")(
replace -
string"
""]]
verb +
+")(
replace -
string"
""]]
verb +
+")(
replace -
string"
""]]
verb +]] + ")(
replace -
string"""]]")(
replace-
string"""]]")(
replace -
string" < ""]]
verb + < + ")(
replace -
string" > ""]]
verb + > + ")(
replace -
string"]]""
")));;
Nowaddtheindentationcommandsandput(...)
aroundthefunctions;(
save -
restriction(
goto -
char(
point -
min))(
search -
forward"
-
V"(
point -
max)
nil1)(
backward -
char2)(
narrow -
to -
region(
point -
min)(
dot))(
goto -
char(
point -
min))(
insert"
section*
Functions""
begindescription")(
while(
search -
forward"
-
F"(
point -
max)
t1)(
delete -
char - 2)(
insert"
item[
sf (")(
end -
of -
line1)(
insert"...)]")(
search -
forward"
-
"(
point -
max)
nil1)(
delete -
char - 1))(
insert"
enddescription"))(
insert"
section*
VariablesVariableswhosedocumentationbeginswithanasterisk`*'
areuserdefinableoptions.
ThesevariablesareusedtocustomizeEmacs.
OthervariablesaregenerallyofinterestonlytoEmacsLispprogrammers.
begindescription")(
while(
search -
forward"
-
V"(
point -
max)
t1)(
delete -
char - 2)(
insert"
item[
sf")(
end -
of -
line1)(
insert"]")(
search -
forward"
-
"(
point -
max)
nil1)(
delete -
char - 1))(
insert"
enddescription""
enddocument